<template>
	<view class="messageCenter">
		<topTitle :title=" $t('mine.message')" />
			
		<view class="list" v-if="messageArr.length">
			<view v-for="(item, idx) in messageArr" :key="idx" @click="goDetail(item)">
				<view>{{item.title}}</view>
				<view class="ovsOne" v-html="item.content"></view>
				<view>{{ formattingTime(item.add_time) }}</view>
			</view>

		</view>
		<noData v-else />

		

	</view>
</template>

<script setup lang="ts">
import { ref,getCurrentInstance } from "vue";
const instance = getCurrentInstance()?.appContext.config.globalProperties;

import { SysNotice } from "@/api/SystemApi";
import { onShow, onReachBottom } from "@dcloudio/uni-app";
let messageArr = ref<Array<any>>([])
let select_time: any = null;

const initFn = async () => {

	let list = await SysNotice({ select_time })
	if (!select_time) {
		messageArr.value = list;
	} else {
		messageArr.value = [...messageArr.value, ...list];
	}
};
const goDetail = async (item:any) => {
	uni.setStorageSync('SysNoticeDetail',item)

	instance?.goTo('/pages/index/messageCenterDetail')

}

onShow(() => {
	initFn()
});
onReachBottom(() => {
	select_time = messageArr.value[messageArr.value.length - 1].add_time;
	initFn();
});

</script>
<style scoped lang="scss">
@import "@/static/scss/messageCenter.scss";
</style>